package com.qf;

import com.mongodb.MongoClient;
import com.mongodb.client.FindIterable;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
import org.junit.Test;

public class test {

    @Test
    public void demo01(){
        MongoClient client = new MongoClient("192.168.58.128");

        MongoDatabase spitdb = client.getDatabase("spitdb");

        MongoCollection<Document> spit = spitdb.getCollection("spit");

        FindIterable<Document> documents = spit.find();

        for (Document document : documents) {
            System.out.println("nickname："+document.get("nickname"));

            System.out.println("_id:"+document.get("_id"));
            System.out.println("=========================");
        }

        client.close();
    }


}
